package com.hotel.service.impl;

import com.hotel.bean.Information;
import com.hotel.exception.SteduException;
import com.hotel.mapper.InformationMapper;
import com.hotel.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InformationServiceImpl implements InformationService {
    @Autowired
    private InformationMapper informationMapper;
    @Override
    public boolean update(Information information) throws SteduException {
        if(informationMapper.selectByIid(information.getIid()) == null){
            throw new SteduException("用户信息不存在");
        }
        return informationMapper.update(information) == 1;
    }

    @Override
    public Information selectByIid(Integer iid) {
        return informationMapper.selectByIid(iid);
    }
    @Override
    public Information selectByAid(Integer aid) {
        Integer iid = informationMapper.selectIidByAid(aid);
        return informationMapper.selectByIid(iid);
    }
}
